/*
 Navicat Premium Dump SQL

 Source Server         : 127.0.0.1
 Source Server Type    : MySQL
 Source Server Version : 50744 (5.7.44)
 Source Host           : 127.0.0.1:3306
 Source Schema         : smart_community

 Target Server Type    : MySQL
 Target Server Version : 50744 (5.7.44)
 File Encoding         : 65001

 Date: 17/09/2025 11:54:53
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for sc_cleaning_task
-- ----------------------------
DROP TABLE IF EXISTS `sc_cleaning_task`;
CREATE TABLE `sc_cleaning_task` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '任务ID',
  `area_id` bigint(20) NOT NULL COMMENT '区域ID',
  `task_name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '任务名称',
  `task_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '任务类型：routine-常规，temporary-临时，special-特殊',
  `scheduled_date` date NOT NULL COMMENT '计划日期',
  `scheduled_time` time DEFAULT NULL COMMENT '计划时间',
  `assigned_user_id` bigint(20) DEFAULT NULL COMMENT '分配用户ID',
  `priority` tinyint(1) NOT NULL DEFAULT '1' COMMENT '优先级：1-低，2-中，3-高，4-紧急',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态：1-待分配，2-已分配，3-进行中，4-已完成，5-已取消',
  `description` text COLLATE utf8mb4_unicode_ci COMMENT '任务描述',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `create_by` bigint(20) DEFAULT NULL COMMENT '创建人ID',
  `update_by` bigint(20) DEFAULT NULL COMMENT '更新人ID',
  `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志：0-未删除，1-已删除',
  `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本号',
  PRIMARY KEY (`id`),
  KEY `idx_area_id` (`area_id`),
  KEY `idx_assigned_user_id` (`assigned_user_id`),
  KEY `idx_scheduled_date` (`scheduled_date`),
  KEY `idx_status` (`status`),
  KEY `idx_priority` (`priority`),
  KEY `idx_create_time` (`create_time`),
  CONSTRAINT `fk_cleaning_task_area` FOREIGN KEY (`area_id`) REFERENCES `sc_cleaning_area` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fk_cleaning_task_user` FOREIGN KEY (`assigned_user_id`) REFERENCES `sc_user` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='保洁任务表';

-- ----------------------------
-- Records of sc_cleaning_task
-- ----------------------------
BEGIN;
INSERT INTO `sc_cleaning_task` (`id`, `area_id`, `task_name`, `task_type`, `scheduled_date`, `scheduled_time`, `assigned_user_id`, `priority`, `status`, `description`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`) VALUES (1, 1, 'task01', 'routine', '2025-01-30', '08:00:00', 46, 1, 2, 'task01', '2025-09-17 11:07:04', '2025-09-17 03:22:08', 42, 42, 0, 0);
INSERT INTO `sc_cleaning_task` (`id`, `area_id`, `task_name`, `task_type`, `scheduled_date`, `scheduled_time`, `assigned_user_id`, `priority`, `status`, `description`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`) VALUES (2, 1, 'task02', 'special', '2025-02-08', '10:30:00', 44, 4, 2, 'task02', '2025-09-17 11:23:04', '2025-09-17 03:28:12', 42, 42, 0, 0);
INSERT INTO `sc_cleaning_task` (`id`, `area_id`, `task_name`, `task_type`, `scheduled_date`, `scheduled_time`, `assigned_user_id`, `priority`, `status`, `description`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`) VALUES (3, 1, 'task03', 'temporary', '2025-02-08', '12:30:00', 42, 2, 2, 'task03', '2025-09-17 11:28:58', '2025-09-17 11:28:58', 42, 42, 0, 0);
INSERT INTO `sc_cleaning_task` (`id`, `area_id`, `task_name`, `task_type`, `scheduled_date`, `scheduled_time`, `assigned_user_id`, `priority`, `status`, `description`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`) VALUES (4, 1, 'task04', 'temporary', '2025-02-08', '10:30:00', 42, 3, 2, 'task04', '2025-09-17 11:36:51', '2025-09-17 11:36:51', 42, 42, 0, 0);
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
